import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

import Login from "@/backstage_1/Login"
import Home from "@/backstage_1/Home"
import WelCome from "@/backstage_1/WelCome";
import Audio from "@/backstage_1/Course/Audio";
import Imgtext from "@/backstage_1/Course/Imgtext";
import Video from "@/backstage_1/Course/Video";
import Commodity from "@/backstage_1/Commodity/Commodity";
import AddCommodity from "@/backstage_1/Commodity/AddCommodity";
import Label from "@/backstage_1/User/Label";
import Rule from "@/backstage_1/User/Rule";
import Sort from "@/backstage_1/Course/Sort";
import Special from "@/backstage_1/Course/Special";
import Svip from "@/backstage_1/User/Svip";
import Vip from "@/backstage_1/User/Vip";
import Coupon from "@/backstage_1/Market/Coupon";
import CouponData from "@/backstage_1/Market/CouponData";
import Condition from "@/backstage_1/User/Condition";
import CourseData from "@/backstage_1/Course/CourseData";
import Reduce from "@/backstage_1/Market/Reduce";
import User from "@/backstage_1/User/User"
import Equity from "@/backstage_1/User/Equity";
import Grow from "@/backstage_1/User/Grow";
import Discount from "@/backstage_1/Market/Discount";
import AddDiscount from "@/backstage_1/Market/AddDiscount";
import Banner from "@/backstage_1/Manager/Banner";
import Emp from "@/backstage_1/Manager/Emp";
import Log from "@/backstage_1/Manager/Log";
import Manager from "@/backstage_1/Manager/Manager";
import Role from "@/backstage_1/Manager/Role";
import ChangeDiscount from "@/backstage_1/Market/ChangeDiscount";
import CourseManage from "@/backstage_1/Course/CourseManage";
import UserDetails from "@/backstage_1/User/UserDetails";
import Seckill from "@/backstage_1/Market/Seckill";
import AddSeckill from "@/backstage_1/Market/AddSeckill";
import ChangeSeckill from "@/backstage_1/Market/ChangeSeckill";
import FreeShip from "@/backstage_1/Market/FreeShip";
import Present from "@/backstage_1/Market/Present";
import Scene from "@/backstage_1/Market/Scene";
import Order from "@/backstage_1/Order/Order";
import OrderDetail from "@/backstage_1/Order/OrderDetail";
import Data from "@/backstage_1/Data/Data";
import Flow from "@/backstage_1/Data/Flow";
import Liveana from "@/backstage_1/Data/Liveana";
import Study from "@/backstage_1/Data/Study";
import Assets from "@/backstage_1/assets/Assets";
import Live from "@/backstage_1/Course/Live";
import LiveAdd from "@/backstage_1/Course/LiveAdd";
import LiveDate from "@/backstage_1/Course/LiveDate";
import LiveUpdate from "@/backstage_1/Course/LiveUpdate";
import Package from "@/backstage_1/Market/Package";
import AddPackage from "@/backstage_1/Market/AddPackage";
import ChangePackage from "@/backstage_1/Market/ChangePackage";
import ReduceData from "@/backstage_1/Market/ReduceData";
import AddSpecial from "@/backstage_1/Course/AddSpecial";
import UpdateSpecial from "@/backstage_1/Course/UpdateSpecial";
import Page0 from "@/backstage_1/Demo/Page0";
import Page1 from "@/backstage_1/Demo/Page1";
import Page2 from "@/backstage_1/Demo/Page2";
import Page3 from "@/backstage_1/Demo/Page3";
import Page4 from "@/backstage_1/Demo/Page4";
import Page5 from "@/backstage_1/Demo/Page5";
import Test from "@/backstage_1/Demo/Test";
const routes = [
  {
    path:"/",
    name:"Login",
    component:Login
  },
  {
    path:"/Login",
    name:"Login",
    component:Login
  },
  {
    path: "/Home",
    name: "/Home",
    component: Home,
    children:[
      {
        path:"/",
        name:"WelCome",
        component:Data
      },
      {
        path:"/Welcome",
        name:"WelCome",
        component:Data
      },
      {
        path:"/Audio",
        name:"Audio",
        component:Audio
      },

      {
        path:"/Imgtext",
        name:"Imgtext",
        component:Imgtext
      },
      {
        path:"/AddSpecial",
        name:"AddSpecial",
        component:AddSpecial
      },
      {
        path:"/UpdateSpecial",
        name:"UpdateSpecial",
        component:UpdateSpecial
      },
      {
        path:"/LiveAdd",
        name:"LiveAdd",
        component:LiveAdd
      },
      {
        path:"/LiveUpdate",
        name:"LiveUpdate",
        component:LiveUpdate
      },
      {
        path:"/LiveDate",
        name:"LiveDate",
        component:LiveDate
      },
      {
        path:"/Live",
        name:"Live",
        component:Live,
      },
      {
        path:"/CourseManage",
        name:"CourseManage",
        component:CourseManage
      },
      {
        path:"/Video",
        name:"Video",
        component:Video
      },
      {
        path:"/Commodity",
        name:"Commodity",
        component:Commodity,
      },
      {
        path:"/AddCommodity",
        name:"AddCommodity",
        component:AddCommodity
      },
      {
        path:"/Label",
        name:"Label",
        component:Label
      },
      {
        path:"/Rule",
        name:"Rule",
        component:Rule
      },
      {
        path:"/Sort",
        name:"Sort",
        component:Sort
      },
      {
        path:"/Special",
        name:"Special",
        component:Special
      },
      {
        path:"/Svip",
        name:"Svip",
        component:Svip
      },
      {
        path:"/Vip",
        name:"Vip",
        component:Vip
      },
      {
        path:"/Coupon",
        name:"Coupon",
        component:Coupon
      },
      {
        path:"/CouponData",
        name:"CouponData",
        component:CouponData
      },
      {
        path:"/CourseData",
        name:"CourseData",
        component:CourseData
      },
      {
        path:"/Reduce",
        name:"Reduce",
        component:Reduce
      },
      {
        path:"/User",
        name:"User",
        component:User
      },
      {
        path:"/Equity",
        name:"Equity",
        component:Equity
      },
      {
        path:"/Grow",
        name:"Grow",
        component:Grow
      },
      {
        path:"/Discount",
        name:"Discount",
        component:Discount
      },
      {
        path:"/Condition",
        name:"Condition",
        component:Condition
      },
      {
        path:"/AddDiscount",
        name:"AddDiscount",
        component:AddDiscount
      },
      {
        path:"/Banner",
        name:"Banner",
        component:Banner
      },
      {
        path:"/Emp",
        name:"Emp",
        component:Emp
      },
      {
        path:"/Log",
        name:"Log",
        component:Log
      },
      {
        path:"/Manager",
        name:"Manager",
        component:Manager
      },
      {
        path:"/Role",
        name:"Role",
        component:Role
      },
      {
        path:"/ChangeDiscount",
        name:"ChangeDiscount",
        component:ChangeDiscount
      },
      {
        path:"/UserDetails",
        name:"UserDetails",
        component:UserDetails
      },
      {
        path:"/birth",
        name:"birth",
        component:Scene
      },
      {
        path:"/Seckill",
        name:"Seckill",
        component:Seckill
      },
      {
        path:"/AddSeckill",
        name:"AddSeckill",
        component:AddSeckill
      },
      {
        path:"/ChangeSeckill",
        name:"ChangeSeckill",
        component:ChangeSeckill
      },
      {
        path:"/FreeShip",
        name:"FreeShip",
        component:FreeShip
      },
      {
        path:"/Order",
        name:"Order",
        component:Order
      },
      {
        path:"/OrderDetail",
        name:"OrderDetail",
        component:OrderDetail
      },

      {
        path:"/Present",
        name:"Present",
        component:Present
      },
      {
        path:"/Data",
        name:"Data",
        component:Data
      },
      {
        path:"/Flow",
        name:"Flow",
        component:Flow
      },
      {
        path:"/Liveana",
        name:"Liveana",
        component:Liveana
      },
      {
        path:"/Study",
        name:"Study",
        component:Study
      },
      {
        path:"/Assets",
        name:"Assets",
        component:Assets
      },
      {
        path:"/Package",
        name:"Package",
        component:Package
      },

      {
        path:"/AddPackage",
        name:"AddPackage",
        component:AddPackage
      },

      {
        path:"/ChangePackage",
        name:"ChangePackage",
        component:ChangePackage
      },

      {
        path:"/CouponData",
        name:"CouponData",
        component:CouponData
      },
      {
        path:"/ReduceData",
        name:"ReduceData",
        component:ReduceData
      },
      {
        path:"/Page0",
        name:"Page0",
        component:Page0
      },
      {
        path:"/Page1",
        name:"Page1",
        component:Page1
      },
      {
        path:"/Page2",
        name:"Page2",
        component:Page2
      },
      {
        path:"/Page3",
        name:"Page3",
        component:Page3
      },
      {
        path:"/Page4",
        name:"Page4",
        component:Page4
      },
      {
        path:"/Page5",
        name:"Page5",
        component:Page5
      },
      {
        path:"/Test",
        name:"Test",
        component:Test
      },
    ]
  }
]


const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach((to,from,next)=>{
  console.log(to,from);
  //你要访问的路径
  let path = to.path;

  if (path == "/" || path == "/Login"){
    next(); //放行   doFilter()
  }else  {
    let user = sessionStorage.getItem("userInfo");
    if (user){
      next();
    }else {
      alert("请先登录!");
      next("/");
    }
  }
})

export default router
